package cn.iocoder.yudao.module.hs.dal.mysql.picktaskmaterialdetail;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.hs.controller.admin.bigscreen.vo.WarehouseCustomerCountData;
import cn.iocoder.yudao.module.hs.controller.admin.picktaskmaterialdetail.vo.PickTaskMaterialDetailPageReqVO;
import cn.iocoder.yudao.module.hs.dal.dataobject.picktaskmaterialdetail.PickTaskMaterialDetailDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 拣货物料明细 Mapper
 *
 * @author 航盛
 */
@Mapper
public interface PickTaskMaterialDetailMapper extends BaseMapperX<PickTaskMaterialDetailDO> {

    default PageResult<PickTaskMaterialDetailDO> selectPage(PickTaskMaterialDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PickTaskMaterialDetailDO>()
                .eqIfPresent(PickTaskMaterialDetailDO::getPickTaskId, reqVO.getPickTaskId())
                .eqIfPresent(PickTaskMaterialDetailDO::getShipOrderId, reqVO.getShipOrderId())
                .eqIfPresent(PickTaskMaterialDetailDO::getMaterialId, reqVO.getMaterialId())
                .likeIfPresent(PickTaskMaterialDetailDO::getMaterialCode, reqVO.getMaterialCode())
                .likeIfPresent(PickTaskMaterialDetailDO::getMaterialName, reqVO.getMaterialName())
                .likeIfPresent(PickTaskMaterialDetailDO::getMaterialModeCode, reqVO.getMaterialModeCode())
                .eqIfPresent(PickTaskMaterialDetailDO::getPickUserId, reqVO.getPickUserId())
                .likeIfPresent(PickTaskMaterialDetailDO::getPickUserName, reqVO.getPickUserName())
                .betweenIfPresent(PickTaskMaterialDetailDO::getPickTime, reqVO.getPickTime())
                .betweenIfPresent(PickTaskMaterialDetailDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PickTaskMaterialDetailDO::getId));
    }

    List<PickTaskMaterialDetailDO> selectListByRfidOrBoxOrMaterial(@Param("code") String code);

    default List<PickTaskMaterialDetailDO> selectListByShipOrderId(Long shipOrderId) {
        return selectList(new LambdaQueryWrapperX<PickTaskMaterialDetailDO>()
                .eq(PickTaskMaterialDetailDO::getShipOrderId, shipOrderId));
    }
}